package com.nvelickovic10.snake.beans.game;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class HiScore implements Serializable {

	private static final long serialVersionUID = -7028539483029254021L;
	private String username;
	private int points;
	private String date;

	public HiScore(String username, int points) {
		this.username = username;
		this.points = points;
		DateFormat df = new SimpleDateFormat("dd.MM.YYY. hh:mm:ss");
		this.date = df.format(new Date());
	}

	public HiScore(String data) {
		String[] datas = data.split("%20");
		username = datas[0];
		points = Integer.valueOf(datas[1]);
		date = datas[2];
	}

	public String getUsername() {
		return username;
	}

	public int getPoints() {
		return points;
	}

	public String getDate() {
		return date;
	}

	@Override
	public String toString() {
		return username + "%20" + points + "%20" + date + "\n";
	}

	@Override
	public boolean equals(Object arg0) {
		HiScore hc = (HiScore) arg0;
		if (username.equals(hc.getUsername()) && points == hc.getPoints()
				&& date.equals(hc.getDate()))
			return true;
		return false;
	}
}
